<?php
	function upfunc(){
		global $_W;
		$webinfo = pdo_get('mii_ang_info',array('uniacid'=>$_W['uniacid']));
		$ad = pdo_fetchall("SELECT imgurl,linkgoodsid FROM ".tablename('mii_ang_ad')."WHERE uniacid=:uniacid AND term >= :term ORDER BY orderid DESC",array(':uniacid'=>$_W['uniacid'],':term'=>$_W['timestamp']));
		$men = pdo_fetchall(" SELECT id,categoryname FROM".tablename('mii_ang_class')." WHERE uniacid=:uniacid AND ishide=:ishide ORDER BY category_order DESC LIMIT 3",array(':uniacid'=>$_W['uniacid'],':ishide'=>'1'));
		$hot = pdo_fetchall("SELECT id,goodsname,titlepic,price FROM".tablename('mii_ang_goods')." WHERE uniacid=:uniacid AND ishot=:ishot",array(':uniacid'=>$_W['uniacid'],':ishot'=>'1'));
		if($webinfo['adinfo']){
			$adinfo = json_decode($webinfo['adinfo'],true);
		}else{
			$adinfo = array('empty'=>'yes');
		}
		$data = array('webinfo'=>$webinfo,'ad'=>$ad,'men'=>$men,'hot'=>$hot,'adinfo'=>$adinfo);
		$siteinfo = json_encode($data);
		$isdata = pdo_get('mii_ang_siteinfo',array('uniacid'=>$_W['uniacid']),array('id'));
		if(!empty($isdata)){
			$up = pdo_update('mii_ang_siteinfo',array('siteinfo'=>$siteinfo),array('uniacid'=>$_W['uniacid']));
		}else{
			$ins = pdo_insert('mii_ang_siteinfo',array('uniacid'=>$_W['uniacid'],'siteinfo'=>$siteinfo));
		}
	}
	upfunc();

?>